#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <netinet/in.h>


int main(int argc, const char *argv[])
{
	int sockfd;
	struct sockaddr_in serveraddr,clientaddr;
	socklen_t addrlen=sizeof(serveraddr);

	//first 创建套接字
	sockfd=socket(AF_INET,SOCK_STREAM,0);

	//second 网络信息结构体填充
	serveraddr.sin_family=AF_INET;
	serveraddr.sin_addr.s_addr=inet_addr(argv[1]);
	serveraddr.sin_port=htons(atoi(argv[2]));

	//third 套接字与服务器网络信息结构体绑定
	bind(sockfd,(struct sockaddr *)&serveraddr,addrlen);
	
	//forth 将套接字设置为被动监听状态
	listen(sockfd,5);

	//fifth 阻塞等待客户端的连接
	accept(sockfd,(struct sockaddr *)&clientaddr,&addrlen);

	printf("lianjie!\n");


	return 0;
}
